/**
 * 本模块主要用于运动健身微服务端提供数据交互功能
 * 创建时间： 2018-02-09
 */

import { ajax } from './ajax.js'

/**
 * 获取上线的轮播图
 */
async function getShufflingImg() {
    let shufflingImgList = await ajax.post('/user/getTrueShuffling')
    return shufflingImgList
}

/**
 * 获取全部课程分类
 */
async function getAllCategories() {
    let allCategories = await ajax.post('/user/getAllCategories')
    return allCategories
}

/**
 * 获取全部课程表
 */
async function getAllCourse(params) {
    let allCourseList = await ajax.post('/user/selectByCondition', params)
    return allCourseList
}

/**
 * 依据课程分类搜索课程
 * @param {课程分类名称, 页数， 每页显示页数} params
 */
async function getCourseByCategory(params) {
    let courseList = await ajax.post('/user/selectByCondition', params)
    return courseList
}

/**
 * 保存用户信息
 * @param {用户信息} params
 */
async function saveUserInfo(params) {
    let userInfo = await ajax.post('/user/addUserTemp', params)
    return userInfo
}

/**
 * 获取订阅号文章
 * @param {获取参数对象} {pageNum, pageSize}
 */
async function getSubscribleArticle(params) {
    let articleList = await ajax.post('/public/getMpHistory', params)
    return articleList
}

/**
 * 查看用户是否订阅
 * @param {用户信息} {"mpId": "900025604", "userId": "100006672"}
 */
async function isSubscrible(params) {
    let subscribeStatus = await ajax.post('/public/isAttention', params)
    return subscribeStatus
}

/**
 * 订阅公众号
 * @param {用户信息} {"mpId": "900025604","userId": "100006672"}
 */
async function subscrible(params) {
    let subscribeInfo = await ajax.post('/public/addAttention', params)
    return subscribeInfo
}

/**
 * 取消订阅公众号
 * @param {用户信息} {"mpId": "900025604","userId": "100006672"}
 */
async function unSubscrible(params) {
    let unSubscribleInfo = await ajax.post('/public/deleteAttention', params)
    return unSubscribleInfo
}

/**
 * 通过RSA获取用户信息
 * @param {} combStr
 */
async function getUserInfoByRSA(params) {
    let userInfo = await ajax.post('/getUserInfoByRSAUrl', params)
    return userInfo
}

export default {
    getShufflingImg,
    getAllCategories,
    getCourseByCategory,
    getAllCourse,
    saveUserInfo,
    getSubscribleArticle,
    isSubscrible,
    subscrible,
    unSubscrible,
    getUserInfoByRSA
}
